/**
 *  CSV Parser
 *  Luciano RUBIO <luciano@loociano.com>
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "Year.hpp"

using namespace std;

/**
 * Constructor
 */
Year::Year()
{

}

/**
 * Destructor
 */
Year::~Year()
{

}

/**
 * Adds a date to the vector of dates
 */
void Year::addDate(Date* date)
{
	cout << "---" << date->getDay() << endl;
	dates.push_back(date);
}

/**
 * Prints total number of dates
 */
void Year::printTotalDates()
{
	cout << "Total dates: " << dates.size() << endl;
}

/**
 * Prints range of dates
 */
void Year::printDates()
{
//	cout << "From: " << *dates.at(0).getDay() << " to "
//			<< *dates.at(dates.size() - 1).getDay() << endl;
}

/**
 * Counts number of items with same name
 */
int Year::countItem(const string& name)
{
	int count = 0;
	for (vector<Date*>::iterator it = dates.begin(); it != dates.end(); ++it)
	{
		count += (*it)->countItem(name);
	}
	return count;
}

/**
 * Counts total number of items
 */
size_t Year::countItems()
{
	size_t count = 0;
	for (vector<Date*>::iterator it = dates.begin(); it != dates.end(); ++it)
	{
		count += (*it)->countItems();
	}
	return count;
}

double Year::countCaloriesIn(const string& name)
{
	double calIn = 0;
	for (vector<Date*>::iterator it = dates.begin(); it != dates.end(); ++it)
	{
		calIn += (*it)->countCaloriesIn(name);
	}
	return calIn;
}

